package com.hw.springcloud.controller;

import com.hw.springcloud.entity.CommonResult;
import com.hw.springcloud.entity.OrderEntity;
import com.hw.springcloud.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Classname: OrderController
 * @Description: 描述
 * @Date: 2021/12/21
 * @Author: HuWei
 */
@RestController
@RequestMapping("/setea/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("/getById/{id}")
    public CommonResult<OrderEntity> linkTest(@PathVariable("id")Long id){
        OrderEntity byId = orderService.getById(id);
        return new CommonResult<>(200,"查询成功",byId);
    }

    @PostMapping("/create")
    public CommonResult createOrder(@RequestBody OrderEntity orderEntity){
        Boolean order = orderService.createOrder(orderEntity);
        return new CommonResult(200,"订单创建成功",order);
    }

    @PostMapping("/update")
    public CommonResult<Boolean> updateOrder(@RequestBody OrderEntity orderEntity){
        Boolean aBoolean = orderService.updateOrder(orderEntity);
        return new CommonResult<>(200,"修改成功",aBoolean);
    }
}
